<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <title>乐热评-因为热爱所以快乐</title>
    <link rel="stylesheet" href="layui/css/layui.css">
    <link rel="stylesheet" href="css/global.css">
    <link rel="stylesheet" type="text/css" href="./alicon/iconfont.css">
    <link rel="stylesheet" href="css/comment.css">


    <meta name="viewport" content="width=device-width, initial-scale=1">
    <script src="js/aes.js"></script>

</head>
<body class="mbg">

<!-- 你的HTML代码 -->
<div class="layui-header header header-doc ">
    <div class="layui-main pbg">
        <a class="logo" href="./index.html"><img src="img/logo.png"/>
        </a>
        <ul class="layui-nav layui-layout-left" lay-filter="">
            <li class="layui-nav-item layui-this"><a href="./index.html">首页</a></li>
            <li class="layui-nav-item"><a href="./search.html">搜索</a></li>

            <li class="layui-nav-item"><a href="./event.html">动态</a></li>
            <li class="layui-nav-item layui-layout-right">
            </li>
        </ul>
    </div>
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</div>


<div class="layui-main pbg">


    <div class="layui-row">
        <div class="layui-col-md6 layui-col-md-offset4 " style="padding: 35px 0px 35px 0px">
            <div class="layui-col-md9">

                <div class="layui-row">
                    <div class="form-box">
                        <div class="form-top">
                            <div class="form-top-left">
                                <p class="ws22 ">登录</p>
                                <p>欢迎来到乐热评。</p>
                            </div>
                            <div class="form-top-right">
                                <i class="fa layui-icon">&#xe688;</i>
                            </div>
                        </div>
                        <div class="form-bottom">
                            <form role="form" action="" method="post" class="login-form">
                                <div class="form-group">
                                    <label class="sr-only" for="form-username">用户名</label>
                                    <input type="text" name="form-username" placeholder="用户名"
                                           class="form-username form-control" id="form-username">
                                </div>
                                <div class="form-group">
                                    <label class="sr-only" for="form-password">密码</label>
                                    <input type="password" name="form-password" placeholder="密码"
                                           class="form-password form-control" id="form-password">
                                </div>
                                <div class="form-group">
                                    <label class="sr-only" for="form-password">验证码</label>
                                    <input type="text" name="form-password" placeholder="验证码"
                                           class="form-password form-control" id="verify">
                                    <div class="inline">
                                        <img id="captchaImg" width="140px" height="60px">
                                        <span style="">看不清，<a href="javascript:void(0);" id="captcha">换一张</a></span>
                                    </div>

                                </div>
                                <button class="btn">登录</button>
                            </form>
                            <p class="float_left"><a href="./findpwd-1.html">找回密码</a></p>
                            <p class="float_right">没有账号，前往<a href="./register.html">注册</a></p>

                        </div>
                    </div>
                </div>


            </div>
        </div>
    </div>

    <div class="footer pbg">
        &copy;Copyright 2018 乐热评<br>
        感谢：<a>Layui</a>,<a>Bootstrap</a>,<a>网易云</a>,<a>QQ音乐</a>,<a>酷我音乐</a>...<br>
        联系我们：<a href="mailto:amoxuk@aliyun.com">amoxuk#aliyun.com(#换成@)</a>
    </div>


</div>
<script type="text/javascript" src="js/jquery-1.12.0.min.js"></script>
<script src="js/jquery.session.js"></script>
<script type="text/javascript" src="js/jquery.flexText.js"></script>
<script src="layui/layui.js"></script>

<script src="js/common.js"></script>
<script src="js/top.js"></script>

<script>
    //注意：导航 依赖 element 模块，否则无法进行功能性操作
    layui.use(['element', 'layer'], function () {
        var element = layui.element;
        var layer = layui.layer;
    });
    $("#captchaImg").attr("src", "captcha?r=" + Date.now());
    $("#captcha").on('click', function () {
        $("#captchaImg").attr("src", "captcha?r=" + Date.now());
    });
    $(".btn").on('click', function () {
        var newTable = {
            "username": $("#form-username").val(),
            "password": aes.encrypt($("#form-password").val()),
            "captcha": $("#verify").val()
        };
        if (!newTable.username || !newTable.password || !newTable.captcha) {
            layer.msg('请先输入必填项。', {icon: 5});
            return false;
        }
        layer.msg('登录中...', {
            icon: 16
            , shade: 0.01
        }, 2000);
        $.ajax({
            type: 'post'
            , url: "/user/login"
            , data: {"data": aes.encrypt(JSON.stringify(newTable))}

            , contentType: 'application/x-www-form-urlencoded;charset=UTF-8'
            , success: function (res) {
                if (1 === res["status"]) {
                    layer.msg(res['msg']);
                    setTimeout("$(\"#captcha\").click()", 2000);
                    return false;
                } else {
                    layer.msg("登录成功！");
                    $.cookie('unLogin', {'statue': true});
                    $.cookie("user", {'user':res.data});
                    self.location = window.history.back();
                    window.location.reload();
                }
                /*self.location = res["msg"];*/

            }
            , error: function (res) {
                layer.msg("错误码：" + res.status + "<br>" + res.statusText);

                setTimeout(" $(\"#reset\").click();", 2000)
            }
        });
        return false;
    });

</script>
<script type="text/javascript" src="js/nearby.js"></script>
</body>
</html>